home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10921 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: gwen.pcug.co.uk!altheim!broldham
  2. Newsgroups: comp.lang.c
  3. Message-ID: <1245@altheim.win-uk.net>
  4. References: <1239@altheim.win-uk.net><18MAR199607594276@erich.triumf.ca> <1242@altheim.win-uk.net><314EC8E6.216E@ix.netcom.com>
  5. Reply-To: broldham@altheim.win-uk.net (Brian R. Oldham)
  6. From: broldham@altheim.win-uk.net (Brian R. Oldham)
  7. Date: Wed, 20 Mar 1996 17:51:39 GMT
  8. Subject: Re: Pointers to register
  9.  
  10.  
  11. In article <314EC8E6.216E@ix.netcom.com>, Norman Bullen (nbullen@ix.netcom.com) writes:
  12. >Brian R. Oldham wrote:
  13. >> 
  14. >> 
  15. >> OK Point taken. But it still leaves the question why my compiler
  16. >> (B.Turbo C/C++ v3.0) accepts the above code, but complains at:
  17. >> 
  18. >>     scancode = &outregs.h.ah;
  19. >> 
  20. >> 
  21. >> ---
  22. >> Brian Oldham
  23. >> Hucknall UK
  24. >> !...Gesundbrunnen 
  25. >scancode is a pointer to an int. &outregs.h.ah is a pointer to something 
  26. >that is not an int; most likely a pointer to an unsigned char. The 
  27. >compiler is right to complain about assigning one kind of pointer to 
  28. >another.
  29. >
  30. >
  31.  
  32. You are quite right.  I checked in dos.h (BYTEREGS) and al, ah etc. are
  33. all unsigned char. So today I went back to my program and changed the
  34. declaration of scancode from pointer to int to a pointer to unsigned
  35. char. Sure enough, my program compiled without complaint, but - guess
  36. what - when I ran it in a main() the bloody system froze.
  37.  
  38. So back to my original question: why does the ostensibly incorrect
  39. declaration:
  40.  
  41.     *ptr = union_member_var;
  42.     
  43. work, and the correct:
  44.  
  45.     ptr = &union_member_var;
  46.     
  47. does not?
  48.  
  49.  
  50.  
  51. ---
  52. Brian Oldham
  53. Hucknall UK
  54. !...Gesundbrunnen
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.